﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;
using System.Drawing;

namespace EdytorWF.Objects
{
    public class LightObject : ModelObject
    {
        private static int counter = 0;
        public Vector3 Direction { get; set; }
        public Color DiffuceColor { get; set;}
        public Color AmbientColor { get; set; }
        public Color SpecularColor { get; set; }

        private float _diffucePower;
        public float DiffucePower
        {
            get
            {
                return _diffucePower;
            }
            set
            {
                _diffucePower = value;
                IEngine.EngineInstance.UpdateLights();
            }
        }
        public float AmbientPower { get; set; }
        public float SpecularPower { get; set; }

        private float _range;
        public float Range
        {
            get
            {
                return _range;
            }
            set
            {
                _range = value;
                IEngine.EngineInstance.UpdateLights();
            }
        }

        public LightType Type { get; set; }
        
        public LightObject(Device device)
        {
            Device = device;

            TypeName = "_LIGHT_OBJECT";
            ObjectName = String.Format("LightObject{0}", counter);
            ++counter;

            Type = LightType.Point;
            DiffuceColor = Color.White;
            AmbientColor = Color.White;
            SpecularColor = Color.White;

            DiffucePower = 0.1f;
            AmbientPower = 0.1f;
            SpecularPower = 0.1f;

            Range = 100;

            Direction = new Vector3(1, 1, 0);
            Position = new Vector3(0, 0, 0);

            MeshFileName = IEngine.EngineInstance.DefaultLightMeshName;
            TextureFileName = IEngine.EngineInstance.DefaultLightTextureName;

            LoadMesh(MeshFileName);
            LoadTexture(TextureFileName);
     
        }

        public override void Move(Vector3 new_position)
        {
            base.Move(new_position);

            Position = new_position;
        }
    }
}
